{extend name="$web_base"/}
{block name="resources"}
<link rel="stylesheet" href="ADDON_NC_ARTICLE_CSS/help.css">
{/block}
{block name="main"}
{php}
	 //文章列表
	  $pid = input('p_id', 0);
	  $page = input('page', 1);
	  $page_size = 10;
	  $category_id = input('category_id', 0);
	  $condition = [];
	  if($category_id != 0) {
		  $condition['category_id'] = $category_id;
	  }
	  $params = [
	     'page' => $page,
	     'page_size' => $page_size,
	     'order' => 'sort asc',
	     'condition' => json_encode($condition),
	  ];
	 $article_list = api('Article.Article.getArticlePageList', $params);
 {/php}
<div class="help-box">
	<div class="crumbs-nav-main clearfix">
		<div class="crumbs-nav-item one-level">
	        <a href="javascript:;" class="crumbs-link">首页</a>
	        <i class="icon icon-angle-right"></i>
	    </div>
	    <div class="crumbs-nav-item">
	        <a href="javascript:;">文章中心</a>
	    </div>
    </div>
	<div class="help-menu">
	 
	 		 {php}
				 $category_list = api("Article.Article.getCategoryTree", []);
				 if(!$category_id) {
				 	$category_id = input('category_id', 0);
				 }
				 if(!$pid) {
				 	$pid = input('p_id', 0);
				 }
				 if($category_id == 0) {
				 	$category_id = $category_list['data'][0]['category_id'];
				 }
				 
			 {/php}
				
			<nav class="menu" data-ride="menu" style="width: 210px">
			  <ul id="tree_menu" class="tree tree-menu" data-animate="true" data-ride="tree">
			   	{if condition="count($category_list['data']) gt 0"}
			    {foreach $category_list['data'] as $k => $v}
			    <li class="{if $v['category_id'] == $pid}open{/if}">
			      <a href="#"><i class="icon"></i>{$v['category_name']}</a>
			      <ul>
			        {if condition="count($v['child_list']) gt 0"}
				      	{foreach $v['child_list'] as $key => $val}
				        	<li class="{if $val['category_id'] == $category_id}active{/if}"><a href="{:addon_url('Article://web/article/index', ['category_id' => $val['category_id'], 'p_id' => $v['category_id']])}"><i class="icon"></i>{$val['category_name']}</a></li>
				        {/foreach}
			        {/if}
			      </ul>
			    </li>
			    {/foreach}
			    {/if}
			  </ul>
			</nav>
			<input type="hidden" id="category_id" value="{$category_id}">
			<input type="hidden" id="pid" value="{$pid}">
	 </div>
	 
	 <div class="help-content">
	 	<div class="list">
		  <!-- 列表项组 -->
		  {if count($article_list['data']['list']) != 0}
			  <section class="items">
			  {foreach $article_list['data']['list'] as $k => $v}
			     <div class="item">
				    <div class="item-heading">
				      <div class="pull-right label label-success">{$v['source']}</div>
				      <h4><a href="{:addon_url('Article://web/article/detail', ['article_id' => $v['article_id']])}">{$v['title']}</a></h4>
				    </div>
				    <div class="item-content">{$v['summary']}</div>
				    <div class="item-footer">
				      <a href="#" class="text-muted"><i class="icon icon-hand-up"></i> {$v['click']}</a> &nbsp; <span class="text-muted">{$v['create_time']|date='Y-m-d H:i:s', ###}</span>
				    </div>
				  </div>
			  {/foreach}
			  </section>
			<ul class="pager" data-ride="pager" data-elements="prev,nav,next,total_page_text,goto" data-page="{$page}" data-rec-per-page="{$page_size}" data-rec-total="{$article_list['data']['count']}" id="pager"></ul>		
		  {else /}
		  <div class="empty">还没有相关内容</div>
		  {/if}
		</div>
	 </div>
	 <div class="clearfix"></div>
	 
 </div>
{/block}
{block name="script"}
<script type="text/javascript">
var category_id = $('#category_id').val();
var pid = $('#pid').val();
$('#pager').pager({
	 linkCreator: function(page, pager) {
	     return nc.url("Article://web/article/index",{ page : page, category_id : category_id, p_id : pid});
	 }
	});
</script>
{/block}